package com.financial.sys.controller.bank;

import com.financial.common.vo.Result;
import com.financial.model.pojo.TRecharge;
import com.financial.sys.query.UserRechargeQuery;
import com.financial.sys.service.bank.TRechargesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "用户充值管理")
@RestController
@RequestMapping("/system")
public class TRechargesController {

    @Autowired
    private TRechargesService tRechargeService;

    @ApiOperation("分页查询用户充值记录")
    @PostMapping("/recharge/query")
    public Result selectLoginLog(@ApiParam(name = "userRechargeQuery",value = "用户充值记录查询对象")
                                             UserRechargeQuery userRechargeQuery){
        Map<String,Object> map=tRechargeService.selectUserRecharge(userRechargeQuery);
        if(map.size()!=0){
            return Result.ok().data(map);
        }
        return Result.error().message("用户充值记录加载失败");
    }


    @ApiOperation("用户充值")
    @PostMapping("/recharge/add")
    public Result UserRechargeAdd(@ApiParam(name = "tRecharge",value = "用户充值对象")
                                              TRecharge tRecharge){
        int i=tRechargeService.UserRechargeAdd(tRecharge);
        if(i>0){
            return Result.ok().data(i);
        }
        return Result.error().message("充值失败!");
    }

}
